from django.db.models import CharField,DateTimeField,IntegerField,ForeignKey,CASCADE,SET_NULL
from apps.vadmin.op_drf.models import CoreModel

class Locations(CoreModel):
    name = CharField(max_length=256,null=True,verbose_name="位置名称")
    manager = ForeignKey(to="permission.UserProfile",on_delete=SET_NULL,null="True",verbose_name="管理员Id",related_name="manage_user")
    ancestors = CharField(max_length=256,null=True,verbose_name="关系树id")
    country = CharField(max_length=128,null=True,verbose_name="国家")
    province = CharField(max_length=128,null=True,verbose_name="省份")
    city = CharField(max_length=128,null=True,verbose_name="城市")
    district = CharField(max_length=128,null=True,verbose_name="区")
    address = CharField(max_length=256,null=True,verbose_name="地址1")
    address2 = CharField(max_length=256,null=True,verbose_name="地址2")
    deleted_datetime = DateTimeField(null=True,verbose_name="删除时间")
    parent_id = IntegerField(null=True,default=0,verbose_name="上级位置")
    image = CharField(max_length=256,null=True,verbose_name="图片url")
    zip = CharField(max_length=10,null=True,verbose_name="邮编")
    currency = CharField(max_length=10,null=True,verbose_name="货币符号")


    class Meta:
        verbose_name = '位置表'
        verbose_name_plural = verbose_name
        ordering = ['id']

    def __str__(self):
        return f"{self.name}"
